<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="公司名称">
              <a-input placeholder="请输入公司名称" v-model="queryParam.companyName"></a-input>
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="职位名称">
              <a-input placeholder="请输入职位名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="工作地点">
              <a-input placeholder="请输入工作地点" v-model="queryParam.workplace"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="学历要求">
              <a-input placeholder="请输入学历要求" v-model="queryParam.educationalRequirement"></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="职位图片">
              <a-input placeholder="请输入职位图片" v-model="queryParam.imgPath"></a-input>
            </a-form-item>
          </a-col> -->
        <template v-if="toggleSearchStatus">
          
          
          
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAddSelf" type="primary" icon="plus">新增</a-button>
     <!--  <a-button type="primary" icon="download" @click="handleExportXls('职位管理')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="previewText" slot-scope="text, record" >
          <a v-if="text" @click="handlePreview(text)" style="margin-left:10px">查看</a>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a @click="handlePublish(record)" v-if="record.status == 0">发布</a>

          <a-divider type="vertical" v-if="record.status == 0"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <companyPosition-modal ref="modalForm" @ok="modalFormOk"></companyPosition-modal>
    <a-modal width="60%" cancelText="关闭" v-model="showPreviewModal" class="pic-preview" title="预览">
      <div v-html="content"></div>
    </a-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import CompanyPositionModal from './modules/CompanyPositionModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "CompanyPositionList",
    mixins:[JeecgListMixin],
    components: {
      CompanyPositionModal
    },
    data () {
      return {
        description: '职位管理管理页面',
        showPreviewModal:false,
        content:'',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   // {
     //        title: '公司名称',
     //        align:"center",
     //        dataIndex: 'companyName'
     //       },
		   // {
     //        title: '职位图片',
     //        align:"center",
     //        dataIndex: 'imgPath'
     //       },
		   {
            title: '职位名称',
            align:"center",
            dataIndex: 'name'
           },
		   {
            title: '工作地点',
            align:"center",
            dataIndex: 'workplace'
           },
		   {
            title: '学历要求',
            align:"center",
            dataIndex: 'educationalRequirement'
           },
		   {
            title: '工作经验',
            align:"center",
            dataIndex: 'workExperience'
           },
		   {
            title: '语言要求',
            align:"center",
            dataIndex: 'languageRequirement'
           },
		   {
            title: '联系人',
            align:"center",
            dataIndex: 'linkman'
           },
           {
            title: '联系方式',
            align:"center",
            dataIndex: 'linkPhone'
           },
		   {
            title: '职位描述',
            align:"center",
            dataIndex: 'jobDescription',
            scopedSlots: { customRender: 'previewText' },
           },
		   {
            title: '职位部门',
            align:"center",
            dataIndex: 'department'
           },
		   {
            title: '任职要求',
            align:"center",
            dataIndex: 'jobRequirements',
            scopedSlots: { customRender: 'previewText' },
           },
		   // {
     //        title: '状态',
     //        align:"center",
     //        dataIndex: 'status'
     //       },
		   {
            title: '浏览量',
            align:"center",
            dataIndex: 'lookCount'
           },
		   {
            title: '转发次数',
            align:"center",
            dataIndex: 'forwardCount'
           },
		   {
            title: '评论次数',
            align:"center",
            dataIndex: 'commentCount'
           },
		   {
            title: '点赞次数',
            align:"center",
            dataIndex: 'fabulousCount'
           },
		   {
            title: '发布时间',
            align:"center",
            dataIndex: 'releaseTime'
           },
		   // {
     //        title: '创建人',
     //        align:"center",
     //        dataIndex: 'createUser'
     //       },
		   // {
     //        title: '更新人',
     //        align:"center",
     //        dataIndex: 'updateUser'
     //       },
		   {
            title: '收藏次数',
            align:"center",
            dataIndex: 'favoriteCount'
           },
           {
            title: '状态',
            align:"center",
            dataIndex: 'status',
            customRender:function (t,r,index) {
              return t==0?'已保存':t==1?'已发布':'';
            }
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/tc/companyPosition/list",
          delete: "/tc/companyPosition/delete",
          deleteBatch: "/tc/companyPosition/deleteBatch",
          exportXlsUrl: "tc/companyPosition/exportXls",
          importExcelUrl: "tc/companyPosition/importExcel",
          publish:"/tc/companyPosition/release"
       },
    }
  },
  created(){
    // let companyId = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')).companyId:'';
    // this.url.list += '?companyId='+companyId;
    // this.loadData();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      handlePreview(content){
        this.showPreviewModal = true;
        this.content = content
      },
      handleAddSelf(){
        let companyId = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')).companyId:'';
        if(!companyId){
          this.$message.error('请先绑定公司')
          return false;
        }
        this.handleAdd();
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>